<?php

namespace app\admin\model\performance;

use think\Model;
use traits\model\SoftDelete;

class Performance extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'performance';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'status_text',
        'gtype_text',
        'ftype_text',
        'i1type_text',
        'i2type_text',
        'i3type_text',
        'di1type_text',
        'di2type_text'
    ];
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getGtypeList()
    {
        return ['0' => __('Gtype 0'), '1' => __('Gtype 1'), '2' => __('Gtype 2')];
    }

    public function getFtypeList()
    {
        return ['0' => __('Ftype 0'), '1' => __('Ftype 1'), '2' => __('Ftype 2')];
    }

    public function getI1typeList()
    {
        return ['0' => __('I1type 0'), '1' => __('I1type 1'), '2' => __('I1type 2')];
    }

    public function getI2typeList()
    {
        return ['0' => __('I2type 0'), '1' => __('I2type 1'), '2' => __('I2type 2')];
    }

    public function getI3typeList()
    {
        return ['0' => __('I3type 0'), '1' => __('I3type 1'), '2' => __('I3type 2')];
    }

    public function getDi1typeList()
    {
        return ['0' => __('Di1type 0'), '1' => __('Di1type 1'), '2' => __('Di1type 2')];
    }
    public function getDi2typeList()
    {
        return ['0' => __('Di2type 0'), '1' => __('Di2type 1'), '2' => __('Di2type 2')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getGtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gtype']) ? $data['gtype'] : '');
        $list = $this->getGtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getFtypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ftype']) ? $data['ftype'] : '');
        $list = $this->getFtypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getI1typeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['i1type']) ? $data['i1type'] : '');
        $list = $this->getI1typeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getI2typeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['i2type']) ? $data['i2type'] : '');
        $list = $this->getI2typeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getI3typeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['i3type']) ? $data['i3type'] : '');
        $list = $this->getI3typeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDi1typeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['di1type']) ? $data['di1type'] : '');
        $list = $this->getDi1typeList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function getDi2typeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['di2type']) ? $data['di2type'] : '');
        $list = $this->getDi2typeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function shop()
    {
        return $this->belongsTo('app\admin\model\wanlshop\Shop', 'shop_id', 'shopname', [], 'LEFT')->setEagerlyType(0);
    }
}
